package com.smartcat.web.actions.selfservice;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.smartcat.model.TranslateData;
import com.smartcat.service.SelfService;
import com.smartcat.web.BaseAction;

@Controller
public class ManageTranslateDataAction extends BaseAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private SelfService selfService;
	
	private String sourceLang;
	private String targetLang;
	private Integer translateDataId;
	
	private String deletemsg;
	
	@Autowired
	public void setSelfService(SelfService selfService) {
		this.selfService = selfService;
	}
	
	public void setSourceLang(String sourceLang) {
		this.sourceLang = sourceLang;
	}

	public void setTargetLang(String targetLang) {
		this.targetLang = targetLang;
	}

	public void setTranslateDataId(Integer translateDataId) {
		this.translateDataId = translateDataId;
	}

	
	public String getDeletemsg() {
		return deletemsg;
	}

	public void setDeletemsg(String deletemsg) {
		this.deletemsg = deletemsg;
	}

	public String deleteTranslateData(){
		selfService.deleteTranslateData(translateDataId);
		this.deletemsg="deleteok";
		return "success";
	}
	
	public String updateTranslateData(){
		TranslateData translateDataInfo=new TranslateData();
		translateDataInfo.setTranslateDataId(translateDataId);
		translateDataInfo.setSourceLang(sourceLang);
		translateDataInfo.setTargetLang(targetLang);
		selfService.updateTranslateData(translateDataInfo);
		return "ok";
	}
}
